﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SingletonDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            //var result = Singleton.Instance().GetName();
            //Console.WriteLine(result);

            //result = Singleton2.Instance().GetName();
            //Console.WriteLine(result);


            //SingleTon2 singleTon2 = new SingleTon2();
            //singleTon2.Update();

            //var i = SingleTon2.Instance().Add();
            //var count = SingleTon2.Instance().Update();


            //var i2 = SingleTon3.Instance().Add();
            //var count2 = SingleTon3.Instance().Update();

            //var i4 = SingleTon4.Instance.Add();
            //var count4 = SingleTon4.Instance.Update();



            //Singleton4.GetInstance().Test1("123");

            //var result = Singleton4.GetInstance().Test2();

            ////Singleton3 singleton3 = new Singleton3();
            ////Singleton3 singleton31 = new Singleton3();
            ////Singleton3 singleton32 = new Singleton3();
            ////Singleton3 singleton33 = new Singleton3();


            //Singleton41.GetInstance().Test1("");
            //Singleton41.GetInstance().Test2();

            //Singleton5.Instance().Test1();
            //var res = Singleton5.Instance().Test2();

            //string a = "小红";
            // a += "小明";
            // a += "小明";
            // a += "小明";
            // a += "小明";

            //StringBuilder stringBuilder = new StringBuilder(); 
            //stringBuilder.Append("小红");
            //stringBuilder.Append("小明");
            //stringBuilder.Append("小明");
            //stringBuilder.Append("小明");

            //string与stringbuilder的区别：
            //1、string和stringbuilder都是引用类型，都是存储在堆内存中，
            //2、string存储数据分配的内存大小是固定不变的，当拼接字符串的时候，会重新分配内存，造成内存的浪费，stringbuilder存储数据分配的内存大小是可变的，当拼接字符串的时候，会自动扩容。


            Singleton6 singleton6 = Singleton6.GetInstance();
            singleton6.Test1();
            singleton6.Test2();
                
            Singleton67 singleton67 = Singleton67.GetInstance;
            singleton67.test1();

            Console.Read();
        }
    }
}
